From 35217964173bc33b1ac0d70ae60ee10bb5410ef5 Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 1 Aug 2005 20:29:56 +0000 Subject: [PATCH] Add 'static' qualifier when we can. (Subtitled "FM: no static at all...") --- gpsbabel/gdb.c | 64 +++++++++++++++++++++--------------------- gpsbabel/hiketech.c | 22 +++++++++++++-- gpsbabel/navicache.c | 20 ++++++------- gpsbabel/overlay.c | 23 +++++++-------- gpsbabel/pathaway.c | 12 +++++++- gpsbabel/psitrex.c | 5 ++-- gpsbabel/trackfilter.c | 22 +++++++-------- 7 files changed, 98 insertions(+), 70 deletions(-) diff --git a/gpsbabel/gdb.c b/gpsbabel/gdb.c index e9a3671ad..dc4d067d5 100644 --- a/gpsbabel/gdb.c +++ b/gpsbabel/gdb.c @@ -104,14 +104,14 @@ static arglist_t gdb_args[] = { * Add a waypoint that we've already written out to our list * */ -void +static void gdb_add_to_hidden(const waypoint *wpt) { waypoint *tmp = waypt_dupe(wpt); route_add_wpt(gdb_hidden, tmp); } -waypoint * +static waypoint * gdb_find_wpt_q_by_name(const queue *whichQueue, const char *name) { queue *elem, *tmp; @@ -126,7 +126,7 @@ gdb_find_wpt_q_by_name(const queue *whichQueue, const char *name) return NULL; } -const char * +static const char * gdb_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format) { static char custom[] = "Custom 63"; @@ -156,7 +156,7 @@ gdb_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format) return DEFAULTICONDESCR; } -int +static int gdb_find_icon_number_from_desc(const char *desc, garmin_formats_e garmin_format) { icon_mapping_t *i; @@ -191,7 +191,7 @@ gdb_find_icon_number_from_desc(const char *desc, garmin_formats_e garmin_format) return def_icon; } -int +static int gdb_detect_rtept_class(const waypoint *wpt) { if (gdb_find_wpt_q_by_name((queue *)&gdb_hidden->waypoint_list, wpt->shortname) == NULL) @@ -202,7 +202,7 @@ gdb_detect_rtept_class(const waypoint *wpt) #ifndef UTF8_SUPPORT -char *gdb_garmin_to_utf8(const char *s) +static char *gdb_garmin_to_utf8(const char *s) { int len; char *res; @@ -247,7 +247,7 @@ char *gdb_garmin_to_utf8(const char *s) /* %%% local functions (read support) %%% */ -char * +static char * gdb_convert_name_buff(char *buff, size_t buffsize) { #ifdef UTF8_SUPPORT @@ -275,7 +275,7 @@ gdb_print_buff(const char *buff, int count, const char *comment) } #endif -waypoint * +static waypoint * gdb_create_rte_wpt(const char *name, double lat, double lon, double alt) { waypoint *wpt; @@ -300,7 +300,7 @@ gdb_create_rte_wpt(const char *name, double lat, double lon, double alt) return wpt; } -size_t +static size_t gdb_fread(void *target, size_t size) { size_t result; @@ -316,7 +316,7 @@ gdb_fread(void *target, size_t size) return result; } -int +static int gdb_fread_str(char *dest, size_t maxlen) { int c; @@ -342,7 +342,7 @@ gdb_fread_str(char *dest, size_t maxlen) fatal(MYNAME ": local buffer overflow detected, please report!\n"); } -int +static int gdb_fread_le(void *dest, size_t size, int bit_count, const char *prefix, const char *field) { char buff[32]; @@ -385,7 +385,7 @@ gdb_fread_le(void *dest, size_t size, int bit_count, const char *prefix, const c } } -int +static int gdb_fread_flag(const char value) /* read one byte and compare to value */ { char c; @@ -394,7 +394,7 @@ gdb_fread_flag(const char value) /* read one byte and compare to value */ return (c == value); } -void +static void gdb_is_valid(int is, const char *prefix, const char *comment) { if (is == 0) @@ -404,7 +404,7 @@ gdb_is_valid(int is, const char *prefix, const char *comment) } } -void +static void gdb_is_validf(int is, const char *prefix, const char *format, ...) { va_list args; @@ -427,7 +427,7 @@ gdb_is_validf(int is, const char *prefix, const char *format, ...) /* %%% read file header */ /********************************************************************************************************/ -void +static void gdb_read_file_header(void) { char buff[128]; @@ -486,7 +486,7 @@ gdb_read_file_header(void) /* %%% read waypoint */ /********************************************************************************************************/ -waypoint * +static waypoint * gdb_read_wpt(const size_t fileofs, int *wptclass) { char xname[GDB_NAME_BUFFERLEN]; @@ -635,7 +635,7 @@ gdb_read_wpt(const size_t fileofs, int *wptclass) /* %%% read route */ /********************************************************************************************************/ -route_head * +static route_head * gdb_read_route(void) { char xname[GDB_NAME_BUFFERLEN]; @@ -785,7 +785,7 @@ gdb_read_route(void) } -route_head * +static route_head * gdb_read_track(const size_t max_file_pos) { char xname[GDB_NAME_BUFFERLEN]; @@ -860,7 +860,7 @@ gdb_read_track(const size_t max_file_pos) /*******************************************************************************/ -void +static void gdb_read_data(void) { int reclen, warnings; @@ -984,7 +984,7 @@ gdb_read_data(void) /* helpers */ -waypoint ** +static waypoint ** gdb_route_point_list(const route_head *route, int *count) { waypoint **result; @@ -1015,13 +1015,13 @@ gdb_route_point_list(const route_head *route, int *count) return result; } -void +static void gdb_fwrite(const void *data, const size_t size) { fwrite(data, size, 1, fout); } -void +static void gdb_fwrite_str(const char *str, const int len) { @@ -1035,7 +1035,7 @@ gdb_fwrite_str(const char *str, const int len) } } -void +static void gdb_fwrite_le(const void *data, const size_t size) { int i; @@ -1070,7 +1070,7 @@ gdb_fwrite_le(const void *data, const size_t size) } } -void +static void gdb_fwrite_alt(const double alt, const double unknown_value) { char c0 = 0; @@ -1085,13 +1085,13 @@ gdb_fwrite_alt(const double alt, const double unknown_value) gdb_fwrite(&c0, 1); /* no value */ } -void +static void gdb_fwrite_int(const int data) { gdb_fwrite_le(&data, sizeof(data)); } -void +static void gdb_fwrite_icon(const waypoint *wpt) /* partly taken from mapsource.c */ { int icon; @@ -1122,7 +1122,7 @@ gdb_fwrite_icon(const waypoint *wpt) /* partly taken from mapsource.c */ /* %%% write file header %%% */ /*-----------------------------------------------------------------------------*/ -void +static void gdb_write_file_header(const struct tm *tm) { char buff[128]; @@ -1159,7 +1159,7 @@ gdb_write_file_header(const struct tm *tm) /* %%% write waypoints %%% */ /*-----------------------------------------------------------------------------*/ -void +static void gdb_write_waypt(const waypoint *wpt, const int hidden) { int i; @@ -1289,7 +1289,7 @@ gdb_write_rtewpt_cb(const waypoint *wpt) /* called by waypt_disp (route points) /* %%% write routes %%% */ /*-----------------------------------------------------------------------------*/ -void +static void gdb_write_route(const route_head *route, const waypoint **list, const int count) { int i, wpt_class; @@ -1474,7 +1474,7 @@ gdb_write_route_cb(const route_head *route) /* %%% write tracks %%% */ /*-----------------------------------------------------------------------------*/ -void +static void gdb_write_track(const route_head *track) { char buff[128]; @@ -1540,7 +1540,7 @@ gdb_write_track_cb(const route_head *track) /* called from track_disp_all */ /*******************************************************************************/ -void +static void gdb_write_data(void) { char c1 = 1; @@ -1571,7 +1571,7 @@ gdb_write_data(void) /*******************************************************************************/ -void +static void gdb_init_opts(const char op) /* 1 = read; 2 = write */ { gdb_via = 0; diff --git a/gpsbabel/hiketech.c b/gpsbabel/hiketech.c index 5e933247c..4daa056bd 100644 --- a/gpsbabel/hiketech.c +++ b/gpsbabel/hiketech.c @@ -73,7 +73,7 @@ static xg_tag_mapping ht_map[] = { { NULL, 0, NULL} }; -void +static void hiketech_rd_init(const char *fname) { xml_init(fname, ht_map, NULL); @@ -115,7 +115,7 @@ hiketech_trk_tlr(const route_head *rte) fprintf(ofd, "\n"); } -void +static void hiketech_print_utc(time_t tm, const char *indent, const char *tag) { char tbuf[80]; @@ -156,7 +156,7 @@ hiketech_waypt_pr(const waypoint *wpt) fprintf(ofd, "\n"); } -void +static void hiketech_write(void) { fprintf(ofd, "\n"); @@ -168,69 +168,82 @@ hiketech_write(void) fprintf(ofd, "\n"); } +static void ht_wpt_s(const char *args, const char **unused) { wpt_tmp = waypt_new(); } +static void ht_ident(const char *args, const char **unused) { wpt_tmp->shortname = xstrdup(args); } +static void ht_sym(const char *args, const char **unused) { wpt_tmp->icon_descr = xstrdup(args); wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1; } +static void ht_lat(const char *args, const char **unused) { wpt_tmp->latitude = atof(args); } +static void ht_long(const char *args, const char **unused) { wpt_tmp->longitude = atof(args); } +static void ht_alt(const char *args, const char **unused) { wpt_tmp->altitude = atof(args); } +static void ht_wpt_e(const char *args, const char **unused) { waypt_add(wpt_tmp); wpt_tmp = NULL; } +static void ht_trk_s(const char *args, const char **unused) { trk_head = route_head_alloc(); track_add_head(trk_head); } +static void ht_trk_e(const char *args, const char **unused) { } +static void ht_trk_ident(const char *args, const char **unused) { trk_head->rte_name = xstrdup(args); } +static void ht_trk_pnt_s(const char *args, const char **unused) { wpt_tmp = waypt_new(); } +static void ht_trk_pnt_e(const char *args, const char **unused) { route_add_wpt(trk_head, wpt_tmp); } +static void ht_trk_utc(const char *args, const char **unused) { struct tm tm; @@ -249,16 +262,19 @@ void ht_trk_utc(const char *args, const char **unused) wpt_tmp->creation_time = utc; } +static void ht_trk_lat(const char *args, const char **unused) { wpt_tmp->latitude = atof(args); } +static void ht_trk_long(const char *args, const char **unused) { wpt_tmp->longitude = atof(args); } +static void ht_trk_alt(const char *args, const char **unused) { wpt_tmp->altitude = atof(args); diff --git a/gpsbabel/navicache.c b/gpsbabel/navicache.c index c2f76ea20..c829b1c9c 100644 --- a/gpsbabel/navicache.c +++ b/gpsbabel/navicache.c @@ -40,19 +40,19 @@ arglist_t nav_args[] = { #define MY_CBUF 4096 #if NO_EXPAT -void +static void nav_rd_init(const char *fname) { fatal(MYNAME ": This build excluded GPX support because expat was not installed.\n"); } -void +static void nav_read(void) { } #else -struct +static struct nc_type_mapping{ geocache_type type; const char *name; @@ -64,7 +64,7 @@ nc_type_mapping{ { gt_event, "event" } }; -struct +static struct nc_container_mapping{ geocache_container type; const char *name; @@ -198,7 +198,7 @@ nav_end(void *data, const char *el) { } -void +static void nav_rd_init(const char *fname) { fd = xfopen(fname, "r", MYNAME); @@ -211,7 +211,7 @@ nav_rd_init(const char *fname) XML_SetElementHandler(psr, nav_start, nav_end); } -void +static void nav_read(void) { int len; @@ -230,26 +230,26 @@ nav_read(void) #endif -void +static void nav_rd_deinit(void) { fclose(fd); } -void +static void nav_wr_init(const char *fname) { fatal(MYNAME ": Does not support writing Navicache files.\n"); ofd = xfopen(fname, "w", MYNAME); } -void +static void nav_wr_deinit(void) { fclose(ofd); } -void +static void nav_write(void) { } diff --git a/gpsbabel/overlay.c b/gpsbabel/overlay.c index aac9e5cf3..b6b69518b 100644 --- a/gpsbabel/overlay.c +++ b/gpsbabel/overlay.c @@ -149,6 +149,7 @@ static int isKeyword(char *str,char **keys) /*----------------------------------------------*/ +static void ovl_rd_init(char const *fname) { fpin = xfopen(fname, "rt", MYNAME); @@ -167,7 +168,7 @@ static struct _group { } *groups; static int groups_cnt; -void ovl_add_group(int aktgrp,char *akttxt) +static void ovl_add_group(int aktgrp,char *akttxt) { int i; @@ -187,7 +188,7 @@ void ovl_add_group(int aktgrp,char *akttxt) /* The name of route is stored in a 'Text'-symbol with identical 'Group'-number. */ -void route_add_name(const route_head *hd) +static void route_add_name(const route_head *hd) { int grp; int i; @@ -211,7 +212,7 @@ void route_add_name(const route_head *hd) strcpy(route->rte_name,name); } -void ovl_read(void) +static void ovl_read(void) { char line[MAXLINE]; int isSection; @@ -391,7 +392,7 @@ void ovl_read(void) xfree(groups); } -void ovl_rd_deinit(void) +static void ovl_rd_deinit(void) { fclose(fpin); } @@ -440,7 +441,7 @@ void ovl_read_parameter(char *fname) } } -void ovl_wr_init(const char *fname) +static void ovl_wr_init(const char *fname) { fpout = xfopen(fname, "wt", MYNAME); govl_sum_n = 0.0; @@ -489,7 +490,7 @@ void ovl_wr_init(const char *fname) } } -void ovl_wr_deinit(void) +static void ovl_wr_deinit(void) { fprintf(fpout,"[Overlay]\n"); fprintf(fpout,"Symbols=%d\n",govl_symbol_cnt); @@ -512,7 +513,7 @@ void ovl_wr_deinit(void) fclose(fpout); } -void symbol_init(const route_head *hd) +static void symbol_init(const route_head *hd) { fprintf(fpout,"[Symbol %d]\n",govl_symbol_cnt+1); fprintf(fpout,"Typ=3\n"); // Linie @@ -527,7 +528,7 @@ void symbol_init(const route_head *hd) govl_group_cnt++; } -void symbol_text(double east,double north,char *text,int group) +static void symbol_text(double east,double north,char *text,int group) { fprintf(fpout,"[Symbol %d]\n",govl_symbol_cnt+1); fprintf(fpout,"Typ=2\n"); // Text @@ -544,7 +545,7 @@ void symbol_text(double east,double north,char *text,int group) govl_symbol_cnt++; } -void symbol_point(const waypoint *wpt) +static void symbol_point(const waypoint *wpt) { double east,north; @@ -563,7 +564,7 @@ void symbol_point(const waypoint *wpt) } -void symbol_deinit(const route_head *hd) +static void symbol_deinit(const route_head *hd) { queue *elem, *tmp; waypoint *waypointp; @@ -670,7 +671,7 @@ static void overlay_waypt_pr(const waypoint *waypointp) } -void ovl_write(void) +static void ovl_write(void) { waypt_disp_all(overlay_waypt_pr); track_disp_all(symbol_init, symbol_deinit, symbol_point); diff --git a/gpsbabel/pathaway.c b/gpsbabel/pathaway.c index 17dc0ac14..ab85b0cf2 100644 --- a/gpsbabel/pathaway.c +++ b/gpsbabel/pathaway.c @@ -106,6 +106,7 @@ internal_debug2(const char *format, ... ) * utilities */ +static char *ppdb_strcat(char *dest, char *src, char *def, int *size) { int len; @@ -137,6 +138,7 @@ static char *str_pool[STR_POOL_SIZE]; static size_t str_pool_s[STR_POOL_SIZE]; static int str_poolp = -1; +static void str_pool_init(void) { int i; @@ -147,6 +149,7 @@ void str_pool_init(void) } } +static void str_pool_deinit(void) { int i; @@ -160,6 +163,7 @@ void str_pool_deinit(void) } } +static char *str_pool_get(size_t size) { char *tmp; @@ -180,6 +184,7 @@ char *str_pool_get(size_t size) return tmp; } +static char *str_pool_getcpy(char *src, char *def) { char *res; @@ -199,6 +204,7 @@ char *str_pool_getcpy(char *src, char *def) * decoding/formatting functions */ +static char *ppdb_fmt_float(const double val) { char *str = str_pool_get(32); @@ -219,6 +225,7 @@ char *ppdb_fmt_float(const double val) return str; } +static char *ppdb_fmt_degrees(char dir, double val) { char *str = str_pool_get(32); @@ -251,6 +258,7 @@ char *ppdb_fmt_degrees(char dir, double val) return str; } +static double ppdb_decode_coord(const char *str) { double val; @@ -284,6 +292,7 @@ double ppdb_decode_coord(const char *str) return val; } +static int ppdb_decode_tm(char *str, struct tm *tm) { int msec, d1, d2, d3, d4; @@ -334,7 +343,8 @@ int ppdb_decode_tm(char *str, struct tm *tm) return 1; } -static int ppdb_read_wpt(const struct pdb *pdb_in, const struct pdb_record *pdb_rec, route_head *head) +static +int ppdb_read_wpt(const struct pdb *pdb_in, const struct pdb_record *pdb_rec, route_head *head) { char *data, *str; double altfeet; diff --git a/gpsbabel/psitrex.c b/gpsbabel/psitrex.c index 4b86b6ca1..9c3da7da9 100755 --- a/gpsbabel/psitrex.c +++ b/gpsbabel/psitrex.c @@ -62,6 +62,7 @@ arglist_t psit_args[] = { }; /* Taken from PsiTrex 1.13 */ +static const psit_icon_mapping_t psit_icon_value_table[] = { { 0x00, "anchor" }, { 0x06, "dollar" }, @@ -144,7 +145,7 @@ const psit_icon_mapping_t psit_icon_value_table[] = { { -1, NULL } }; -const char * +static const char * psit_find_desc_from_icon_number(const int icon) { const psit_icon_mapping_t *i; @@ -157,7 +158,7 @@ psit_find_desc_from_icon_number(const int icon) return ""; } -int +static int psit_find_icon_number_from_desc(const char *desc) { const psit_icon_mapping_t *i; diff --git a/gpsbabel/trackfilter.c b/gpsbabel/trackfilter.c index dbfeddd19..acd1bb43b 100644 --- a/gpsbabel/trackfilter.c +++ b/gpsbabel/trackfilter.c @@ -104,7 +104,7 @@ trackfilter_noop_t(const route_head *h) * helpers *******************************************************************************/ -int +static int trackfilter_opt_count(void) { int res = 0; @@ -118,7 +118,7 @@ trackfilter_opt_count(void) return res; } -int +static int trackfilter_parse_time_opt(const char *arg) { time_t t0, t1; @@ -219,7 +219,7 @@ trackfilter_fill_track_list_cb(const route_head *track) /* callback for track_d * track title producers *******************************************************************************/ -void +static void trackfilter_split_init_rte_name(route_head *track, const time_t time) { char buff[128], tbuff[128]; @@ -254,7 +254,7 @@ trackfilter_split_init_rte_name(route_head *track, const time_t time) track->rte_name = xstrdup(buff); } -void +static void trackfilter_pack_init_rte_name(route_head *track, const time_t default_time) { char buff[128]; @@ -287,7 +287,7 @@ trackfilter_pack_init_rte_name(route_head *track, const time_t default_time) * option "title" *******************************************************************************/ -void +static void trackfilter_title(void) { int i; @@ -308,7 +308,7 @@ trackfilter_title(void) * option "pack" (default) *******************************************************************************/ -void +static void trackfilter_pack(void) { int i, j; @@ -346,7 +346,7 @@ trackfilter_pack(void) * option "merge" *******************************************************************************/ -void +static void trackfilter_merge(void) { int i, j, dropped; @@ -404,7 +404,7 @@ trackfilter_merge(void) * option "split" *******************************************************************************/ -void +static void trackfilter_split(void) { route_head *curr; @@ -540,7 +540,7 @@ trackfilter_split(void) * option "move" *******************************************************************************/ -void +static void trackfilter_move(void) { int i; @@ -568,7 +568,7 @@ trackfilter_move(void) * option: "start" / "stop" *******************************************************************************/ -time_t +static time_t trackfilter_range_check(const char *timestr) { int i; @@ -595,7 +595,7 @@ trackfilter_range_check(const char *timestr) return mkgmtime(&time); } -int +static int trackfilter_range(void) /* returns number of track points left after filtering */ { time_t start, stop; -- 2.30.2